package tutorial;

import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

// must use Spring runner
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-config.xml")
public class SpringClient {
	// use autowired to get the attribute from spring
	@Autowired
	protected HelloWorld helloClient;

	@Test
	public void testHello() {
		String text;
		try {
			text = helloClient.hello("test");
			System.out.println(text);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	@After
	public void tearDown() {
		helloClient.stop();
	}
}
